package com.hongminzheng.openapi.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hongminzheng.openapi.mapper.RouteMapper;
import com.hongminzheng.openapi.pojo.Route;
import com.hongminzheng.openapi.service.RouteService;
import lombok.extern.log4j.Log4j;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author hmz
 * @version v1.0
 * @data 2020/09/29
 **/

@Service
@Transactional(rollbackFor = Exception.class)
@Log4j
public class RouteServiceImpl implements RouteService {

    @Autowired
    private RouteMapper routeMapper;


    @Override
    public int deleteByPrimaryKey(Integer id) {
        return routeMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int insert(Route route) {
        return routeMapper.insert(route);
    }

    @Override
    public int insertSelective(Route route) {
        return routeMapper.insertSelective(route);
    }

    @Override
    public Route selectByPrimaryKey(Integer id) {
        return routeMapper.selectByPrimaryKey(id);
    }

    @Override
    public int updateByPrimaryKeySelective(Route route) {
        return routeMapper.updateByPrimaryKeySelective(route);
    }

    @Override
    public int updateByPrimaryKey(Route route) {
        return routeMapper.updateByPrimaryKey(route);
    }

    @Override
    public PageInfo<Route> findPage(Integer pageNum, Integer pageSize, Route route) {
        PageHelper.startPage(pageNum, pageSize);
        List<Route> routes = routeMapper.findByGatewayApiName(route);
        PageInfo<Route> pageInfo = new PageInfo<>(routes);
        return pageInfo;
    }

}
